﻿using System.IO;

namespace uREST.Core.Extensions
{
    public static class FileInfoExtensions
    {
        public static string GetMimeType(this FileInfo fileInfo)
        {
            var mime = "application/octetstream";
            var ext = fileInfo.Extension;
            var rk = Microsoft.Win32.Registry.ClassesRoot.OpenSubKey(ext);
            if (rk != null && rk.GetValue("Content Type") != null)
                mime = rk.GetValue("Content Type").ToString();
            return mime;
        }
    }
}
